﻿using System;
using System.ComponentModel;
using System.Drawing.Design;

using TeamDeployer.TeamFoundation.Build.Workflow.Design;

namespace TeamDeployer.TeamFoundation.Build.Workflow.CustomTypes
{
     
     [Serializable, TypeConverter(typeof(DatabaseSpecConverter)), DefaultProperty("Target Server"), Editor(
        typeof(DatabaseSpecEditor), typeof(UITypeEditor))]
   public  class DatabaseSpec
    {
         public DatabaseSpec()
         {
             this.Deploy = true;
         }
         [ DisplayName("Target Server"), Description(
            "The target server name"), Category(
            "Target"), RefreshProperties(RefreshProperties.All)]
         public string TargetServer { get; set; }

         [DisplayName("Target Database"), Description(
            "The target database name"), Category(
            "Target"), RefreshProperties(RefreshProperties.All)]
        public string TargetDatabase { get; set; }

         [ DisplayName("Project Path"), Description(
            "The relative path to the project"), Category(
            "Project"), RefreshProperties(RefreshProperties.All)]
        public string ProjectPath { get; set; }

         [DisplayName("Deploy to server?"), Description(
            "Can the project be deployed to server"), Category(
            "Project"), RefreshProperties(RefreshProperties.All)]
        public bool Deploy { get; set; }

        [Browsable(false)]
        public Guid Id { get; set; }


        [Browsable(false)]
        public bool HasConfiguration
        {
            get
            {
                return (!string.IsNullOrEmpty(TargetServer) && !string.IsNullOrEmpty(TargetDatabase));
            }
        }

        public DatabaseSpec Clone()
        {
            return new DatabaseSpec
            {
                TargetServer = this.TargetServer,
                TargetDatabase=this.TargetDatabase,
                ProjectPath=this.ProjectPath,
                Deploy=this.Deploy ,
                Id=this.Id 
            };

        }

       
    }
}
